{#include file="header.html"#}

	{#if $action == 'list'#}
    <h3 class="title"><em>{#$pagetitle#}</em><span><a href="{#$fileurl#}?act=add">+添加新站点</a></span></h3>
	<div class="listbox">
		<form name="mform" method="post" action="{#$fileurl#}">
		<div class="search">
			<input name="keywords" type="text" id="keywords" class="ipt" size="30" value="{#$keywords#}" />
			<input type="submit" class="btn" value="搜索" />
        </div>
        </form>
                    
		<form name="mform" method="post" action="{#$fileurl#}">
		<div class="toolbar">
			<select name="act" id="act" class="sel">
			<option value="del" style="color: #f00;">删除选定</option>
            <option value="move" style="color: #06c;">移动内容</option>
            <option value="attr" style="color: #f60;">属性设置</option>
			</select>
			<input type="submit" class="btn" value="应用" onClick="if(IsCheck('web_id[]')==false){alert('请指定您要操作的站点ID！');return false;}else{return confirm('确认执行此操作吗？');}">
			<select class="sel" onChange="if(this.options[this.selectedIndex].value!=''){location='{#$fileurl#}?status='+this.options[this.selectedIndex].value+'&cate_id={#$cate_id#}&sort={#$sort#}&order={#$order#}{#$key_url#}';}">
			<option value="0">所有状态</option>
			<option value="1" style="color: #333;"{#opt_selected($status, 1)#}>拉黑</option>
			<option value="2" style="color: #f30;"{#opt_selected($status, 2)#}>待审核</option>
			<option value="3" style="color: #080;"{#opt_selected($status, 3)#}>已审核</option>
			</select>
			<select class="sel" onChange="if(this.options[this.selectedIndex].value!=''){location='{#$fileurl#}?status={#$status#}&cate_id='+this.options[this.selectedIndex].value+'&sort={#$sort#}&order={#$order#}{#$key_url#}';}">
			<option value="0" selected>所有分类</option>
			{#$category_option#}
			</select>
			<select class="sel" onChange="if(this.options[this.selectedIndex].value!=''){location='{#$fileurl#}?status={#$status#}&cate_id={#$cate_id#}&sort='+this.options[this.selectedIndex].value+'{#$key_url#}';}">
			<option value="1"{#opt_selected($sort, 1)#}>按时间排列</option>
			<option value="2"{#opt_selected($sort, 2)#}>按PR排列</option>
			<option value="3"{#opt_selected($sort, 3)#}>按Alexa排列</option>
			<option value="4"{#opt_selected($sort, 4)#}>按入站排列</option>
			<option value="5"{#opt_selected($sort, 5)#}>按出站排列</option>
			<option value="6"{#opt_selected($sort, 6)#}>按浏览排列</option>
			</select>
			<select class="sel" onChange="if(this.options[this.selectedIndex].value!=''){location='{#$fileurl#}?status={#$status#}&cate_id={#$cate_id#}&sort={#$sort#}&order='+this.options[this.selectedIndex].value+'{#$key_url#}';}">
			<option value="DESC"{#opt_selected($order, 'DESC')#}>降序</option>
			<option value="ASC"{#opt_selected($order, 'ASC')#}>升序</option>
			</select>
		</div>
		
    	<table width="100%" border="0" cellspacing="1" cellpadding="0">
			<tr>
				<th><input type="checkbox" id="ChkAll" onClick="CheckAll(this.form)"></th>
				<th>ID</th>
				<th>所属分类</th>
				<th>网站名称</th>
				<th>PR</th>
				<th>Alexa</th>
				<th>入站次数</th>
				<th>出站次数</th>
				<th>浏览次数</th>
				<th>属性状态</th>
				<th>收录时间</th>
				<th>操作选项</th>
			</tr>
			{#foreach from=$websites item=row#}
			<tr>
				<td><input name="web_id[]" type="checkbox" value="{#$row.web_id#}"></td>
				<td>{#$row.web_id#}</td>
				<td>{#$row.web_cate#}</td>
				<td class="ltext">{#$row.web_name#}</td>
				<td class="data">{#$row.web_grank#}</td>
				<td class="data">{#$row.web_arank#}</td>
				<td class="data">{#$row.web_instat#}</td>
				<td class="data">{#$row.web_outstat#}</td>
				<td class="data">{#$row.web_views#}</td>
				<td>{#$row.web_attr#}</td>
				<td>{#$row.web_ctime#}</td>
				<td>{#$row.web_oper#}</td>
			</tr>
			{#foreachelse#}
			<tr><td colspan="12">无任何网站！</td></tr>
			{#/foreach#}
		</table>
        </form>
        <div class="pagebox">{#$showpage#}</div>
    </div>
    {#/if#}

	{#if $action == 'add' || $action == 'edit'#}
    <h3 class="title"><em>{#$pagetitle#}</em><span><a href="{#$fileurl#}">返回列表&nbsp;&rsaquo;&nbsp;</a></span></h3>
	<div class="formbox">
    	<form name="mform" method="post" action="{#$fileurl#}">
		<table width="100%" border="0" cellspacing="1" cellpadding="0">
			<tr>
				<th>所属分类：</th>
				<td>{#foreach from=$cate_pids item=item key=key#}<select name="level_{#$key#}" id="level_{#$key#}" class="sel"></select>{#foreachelse#}<select name="level_0" id="level_0" class="sel"></select>{#/foreach#}<input type="hidden" name="cate_id" id="cate_id" value="{#$row.cate_id#}"></td>
			</tr>
			<tr>
				<th>网站名称：</th>
				<td><input name="web_name" type="text" class="ipt" id="web_name" size="50" maxlength="50" value="{#$row.web_name#}" /></td>
			</tr>
			<tr>
				<th>网站域名：</th>
				<td><input name="web_url" type="text" class="ipt" id="web_url" size="50" maxlength="255" value="{#$row.web_url#}" onKeyPress="strip_http()" onChange="strip_http()" onKeyUp="strip_http()" /><input type="button" class="btn" id="meta_btn" value="抓取Meta" onclick="get_meta();"><span class="tips">必须输入https或者http</span></td>
			</tr>
			<tr>
				<th>网站标题：</th>
				<td><input name="web_title" type="text" class="ipt" id="web_title" size="50" maxlength="100" value="{#$row.web_title#}" /><span class="tips">标题长度限制在80个字符以内</span></td>
			</tr>
			<tr>
				<th>TAG标签：</th>
				<td><input name="web_tags" type="text" class="ipt" id="web_tags" size="50" maxlength="255" value="{#$row.web_tags#}" onBlur="javascript:this.value=this.value.replace(/，/ig,',');" /><span class="tips">多个标签用英文的“,”逗号隔开</span></td>
			</tr>
			<tr>
				<th valign="top">网站描述：</th>
				<td><textarea name="web_intro" cols="55" rows="8" class="ipt" id="web_intro">{#$row.web_intro#}</textarea></td>
			</tr>
            <tr>
				<th>服务器IP：</th>
				<td><input name="web_ip" type="text" class="ipt" id="web_ip" size="30" maxlength="30" value="{#$row.web_ip#}" /><input type="button" class="btn" id="data_btn" value="获取数据" onclick="get_wdata();"><span class="tips">例: 127.0.0.1</span></td>
			</tr>
 			<tr>
				<th>BaiduRank：</th>
				<td><input name="web_brank" type="text" class="ipt" id="web_brank" size="10" maxlength="1" value="{#(!$row.web_brank) ? '0' : $row.web_brank#}" /></td>
			</tr>
 			<tr>
				<th>PageRank：</th>
				<td><input name="web_grank" type="text" class="ipt" id="web_grank" size="10" maxlength="1" value="{#(!$row.web_grank) ? '0' : $row.web_grank#}" /></td>
			</tr>
 			<tr>
				<th>SogouRank：</th>
				<td><input name="web_srank" type="text" class="ipt" id="web_srank" size="10" maxlength="1" value="{#(!$row.web_srank) ? '0' : $row.web_srank#}" /></td>
			</tr>
 			<tr>
				<th>AlexaRank：</th>
				<td><input name="web_arank" type="text" class="ipt" id="web_arank" size="10" maxlength="10" value="{#(!$row.web_arank) ? '0' : $row.web_arank#}" /></td>
			</tr>
 			<tr>
				<th>点入次数：</th>
				<td><input name="web_instat" type="text" class="ipt" id="web_instat" size="10" maxlength="10" value="{#(!$row.web_instat) ? '0' : $row.web_instat#}" /> 次</td>
			</tr>
 			<tr>
				<th>点出次数：</th>
				<td><input name="web_outstat" type="text" class="ipt" id="web_outstat" size="10" maxlength="10" value="{#(!$row.web_outstat) ? '0' : $row.web_outstat#}" /> 次</td>
			</tr>
 			<tr>
				<th>浏览次数：</th>
				<td><input name="web_views" type="text" class="ipt" id="web_views" size="10" maxlength="10" value="{#(!$row.web_views) ? '0' : $row.web_views#}" /> 次</td>
			</tr>
			<tr>
				<th>错误次数：</th>
				<td><input name="web_errors" type="text" class="ipt" id="web_errors" size="10" maxlength="10" value="{#(!$row.web_errors) ? '0' : $row.web_errors#}" /> 次</td>
			</tr>
			<tr>
				<th>属性设置：</th>
				<td><input name="web_ispay" type="checkbox" id="web_ispay" value="1"{#opt_checked($row.web_ispay, 1)#} /><label for="web_ispay">付费</label>　<input name="web_istop" type="checkbox" id="web_istop" value="1"{#opt_checked($row.web_istop, 1)#} /><label for="web_istop">置顶</label>　<input name="web_isbest" type="checkbox" id="web_isbest" value="1"{#opt_checked($row.web_isbest, 1)#} /><label for="web_isbest">推荐</label></td>
			</tr>
			<tr>
				<th>审核状态：</th>
				<td><select name="web_status" id="web_status" class="sel"><option value="1" style="color: #333;"{#opt_selected($status, 1)#}>黑名单</option><option value="2" style="color: #f30;"{#opt_selected($status, 2)#}>待审核</option><option value="3" style="color: #080;"{#opt_selected($status, 3)#}>已审核</option></select></td>
			</tr>
			<tr class="btnbox">
            	<th>&nbsp;</th>
				<td>
					<input name="act" type="hidden" id="act" value="{#$h_action#}">
					{#if $action == 'edit' && $row.web_id#}
					<input name="web_id" type="hidden" id="web_id" value="{#$row.web_id#}">
					{#/if#}
					<input type="submit" class="btn" value="保 存">&nbsp;
					<input type="reset" class="btn" value="取 消" onClick="window.location.href='{#$fileurl#}';">
				</td>
			</tr>
		</table>
        </form>
        <script type="text/javascript" src="../public/scripts/linkage.select.js"></script>
        <script type="text/javascript">
		var options = {ajax : '../?mod=ajaxget&type=category', field_name : '[name=cate_id]', auto : true}
		var sel = new LinkageSelect(options);
		{#if $action == 'add'#}
		sel.bind('#level_0');
		{#else#}
		{#foreach from=$cate_pids item=item key=key#}
		sel.bind('#level_{#$key#}', {#$item#});
		{#/foreach#}
		{#/if#}
        </script>
	</div>
	{#/if#}
	
	{#if $action == 'move'#}
    <h3 class="title"><em>{#$pagetitle#}</em><span><a href="{#$fileurl#}">返回列表&nbsp;&rsaquo;&nbsp;</a></span></h3>
	<div class="formbox">
		<form name="mform" method="post" action="{#$fileurl#}">
		<table width="100%" border="0" cellspacing="1" cellpadding="0">
			<tr>
				<th valign="top">已选定的内容：</th>
				<td>{#foreach from=$websites item=row#}<a href="{#$fileurl#}&act=edit&web_id={#$row.web_id#}">{#$row.web_name#}</a><input name="web_id[]" type="hidden" value="{#$row.web_id#}"><br />{#/foreach#}</td>
			</tr>
			<tr>
				<th>将以上内容移动至：</th>
				<td><select name="cate_id" id="cate_id" class="sel">{#$category_option#}</select></td>
			</tr>
			<tr class="btnbox">
            	<th>&nbsp;</th>
				<td>
					<input name="act" type="hidden" id="act" value="{#$h_action#}">
					<input type="submit" class="btn" value="保 存">&nbsp;
					<input type="reset" class="btn" value="取 消" onClick="window.location.href='{#$fileurl#}';">
				</td>
			</tr>
		</table>
		</form>
	</div>
	{#/if#}
    
	{#if $action == 'attr'#}
    <h3 class="title"><em>{#$pagetitle#}</em><span><a href="{#$fileurl#}">返回列表&nbsp;&rsaquo;&nbsp;</a></span></h3>
	<div class="formbox">
		<form name="mform" method="post" action="{#$fileurl#}">
		<table width="100%" border="0" cellspacing="1" cellpadding="0">
			<tr>
				<th valign="top">已选定的内容：</th>
				<td>{#foreach from=$websites item=row#}{#$row.web_id#} - <a href="{#$fileurl#}&act=edit&web_id={#$row.web_id#}">{#$row.web_name#}</a><input name="web_id[]" type="hidden" value="{#$row.web_id#}"><br />{#/foreach#}</td>
			</tr>
			<tr>
				<th>属性设置：</th>
				<td><input name="web_ispay" type="checkbox" id="web_ispay" value="1" /><label for="web_ispay">付费</label> <input name="web_istop" type="checkbox" id="web_istop" value="1" /><label for="web_istop">置顶</label>　<input name="web_isbest" type="checkbox" id="web_isbest" value="1" /><label for="web_isbest">推荐</label></td>
			</tr>
			<tr>
				<th>审核状态：</th>
				<td><select name="web_status" id="web_status" class="sel"><option value="1" style="color: #333;">黑名单</option><option value="2" style="color: #f30;">待审核</option><option value="3" selected="selected" style="color: #080;">已审核</option></select></td>
			</tr>
			<tr class="btnbox">
            	<th>&nbsp;</th>
				<td colspan="2">
				<input name="act" type="hidden" id="act" value="{#$h_action#}">
				<input type="submit" class="btn" value="保 存">&nbsp;
				<input type="reset" class="btn" value="取 消" onClick="window.location.href='{#$fileurl#}';">
				</td>
			</tr>
		</table>
		</form>
	</div>
	{#/if#}

{#include file="footer.html"#}